﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Forms;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.SqlClient;
using Power.Model;
using Power.DAL;


namespace Power
{
    /// <summary>
    /// Locate.xaml 的交互逻辑
    /// </summary>
    public partial class Locate : Window
    {
        public Locate()
        {
            InitializeComponent();
        }




        public string username
        {
            get;
            set;
        }

        public string device
        {
            get;
            set;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string stPath = System.Windows.Forms.Application.StartupPath.ToString() + "\\GoogleMap.html";
            WebMap.Navigate(stPath);
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {


            //string texttose;
            //List<Monitor> list = new List<Monitor>();
            //DataTable ds = SqlHelper.ExecuteDataTable("select * from T_test2 where Device=@Device", new SqlParameter("@Device", Tosearch.Text));


            //DataRow row2 = ds.Rows[0];

            //texttose = row2["GPSJ"] + "," + row2["GPSW"] + "," + row2["Device"] + "," + row2["TempL"] + "," + row2["TempH"];

            Monitorc tempm = new Monitorc();
            tempm = new MonitorDAL().ToFind(device);

            string[] strGPS;
            object[] arg = new object[5];
            string texttose;
            texttose = tempm.GPSL + "," + tempm.GPSW + "," + tempm.Device + "," + tempm.TempI + "," + tempm.TempO;


            strGPS = texttose.Split(',');
            arg[0] = (object)strGPS[0];
            arg[1] = (object)strGPS[1];
            arg[2] = (object)strGPS[2];
            arg[3] = (object)strGPS[3];
            arg[4] = (object)strGPS[4];
            WebMap.InvokeScript("movemarker", arg);

            arg[0] = (object)strGPS[0];
            arg[1] = (object)strGPS[1];
            arg[2] = (object)strGPS[2];
            arg[3] = (object)strGPS[3];
            arg[4] = (object)strGPS[4];
            WebMap.InvokeScript("flyto", arg);





















        }
    }
}
